/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package InternetHax;

/**
 * Queue implementation using a vector, blocks until there are objects
 * http://code.google.com/p/j2me-mpeg/source/browse/trunk/Queue.java
 * 
 */
import java.util.Vector;

public class Queue {

    private Vector queue = new Vector();

    public void put(Object obj) {
        synchronized (queue) {
            queue.addElement(obj);
            queue.notify();
        }
    }
    
    public Object get() {
        synchronized (queue) {
            while (queue.isEmpty()) {
                try {
                    queue.wait();
                } catch (InterruptedException ignore) {
                    return null;
                }
            }

            Object obj = queue.firstElement();
            queue.removeElementAt(0);
            return obj;
        }
    }
}

